<template>
  <BasicModal
    width="50%"
    :min-height="500"
    :show-ok-btn="false"
    v-bind="$attrs"
    @register="registerModal"
    title="查看"
  >
    <div class="h-200 flex-1">
      <Designer v-if="processXml" :xml="processXml" :readOnly="true" />
    </div>
  </BasicModal>
</template>

<script lang="ts">
  import { defineComponent, ref } from 'vue';

  import { BasicModal, useModalInner } from '/@/components/Modal';
  import { Designer } from '/@/components/BpmnChart';

  import { getReviewFlowApi } from '/@/api/flow/temp';
  export default defineComponent({
    name: 'FlowChatReview',
    components: { BasicModal, Designer },
    setup() {
      const processXml = ref('');
      const [registerModal, { closeModal, changeLoading }] = useModalInner(async (data) => {
        try {
          changeLoading(true);
          await init(data);
        } catch (e) {
          throw e;
        } finally {
          changeLoading(false);
        }
      });

      async function init(data) {
        processXml.value = '';
        const xml = await getReviewFlowApi(data.params);

        processXml.value = xml;
      }
      return {
        processXml,
        registerModal,
        closeModal,
      };
    },
  });
</script>
<style lang="less" scoped></style>
